﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
using System.Reflection;
using System.Drawing;
using DailyPhoto.Common;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Bson.Serialization;
using Newtonsoft.Json;

namespace DailyPhoto.Entities
{
    public class BlackEntry
    {
        public ObjectId Id { get; set; }
        public string RepositoryName { get; set; }
        public DateTime? Date { get; set; }
        public string PhotoId { get; set; }
    }

    public class BlackList
    {
        public BlackList()
        {
            dbBlackList = Database.GetCollection<BlackEntry>("blacklist");
        }


        public void Insert(BlackEntry entry)
        {
            dbBlackList.Insert(entry);
        }


        public IEnumerable<BlackEntry> GetEntriesOfRepository(string repostiory)
        {
            if (repostiory == null)
                return dbBlackList.FindAll();

            return dbBlackList.Find(Query.EQ("RepositoryName", repostiory)).ToList();
        }

        private MongoCollection<BlackEntry> dbBlackList;
    }
}
